package com.android.baseconfig.data.http.retrofit2.func;

import com.android.baseconfig.base.BaseApiResult;
import com.android.baseconfig.data.http.retrofit2.exception.ApiException;

import io.reactivex.rxjava3.functions.Function;

/**
 * description:Handle_Fuc
 * Author:  howard gong
 * Create:  2017/3/2 20:28
 */

public class Handle_Fuc<T> implements Function<T, T> {

    @Override
    public T apply(T response) throws Exception {
        if (ApiException.isOk(((BaseApiResult)response).status)) {
            return response;
        } else {
            throw new ApiException(((BaseApiResult)response).status, ((BaseApiResult)response).message);
        }
    }
}
